<?php
	require_once("../conexion/conexion.php");
	$fecha = date("d/m/Y");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<style>
#Normal
{
border:1px solid #D3E4E5;
}
#texto
{
	font-family:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC; 
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}
</style>
<script>
function puntitos(donde,caracter)
{
	pat = /[\*,\+,\(,\),\?,\,$,\[,\],\^]/;
	valor = donde.value;
	largo = valor.length;
	crtr = true;
	if(isNaN(caracter) || pat.test(caracter) == true)
	{
		if (pat.test(caracter)==true)
		{ 
			caracter = "\"" + caracter;
		}
		carcter = new RegExp(caracter,"g");
		valor = valor.replace(carcter,"");
		donde.value = valor;
		crtr = false;
	}
	else
	{
		var nums = new Array();
		cont = 0;
		for(m=0;m<largo;m++)
		{
			if(valor.charAt(m) == "." || valor.charAt(m) == " ")
				{continue;}
			else
			{
				nums[cont] = valor.charAt(m);
				cont++;
			}
		}
	}
	var cad1="",cad2="",tres=0;
	if(largo > 3 && crtr == true)
	{
		for (k=nums.length-1;k>=0;k--)
		{
			cad1 = nums[k];
			cad2 = cad1 + cad2;
			tres++;
			if((tres%3) == 0)
			{
				if(k!=0)
				{
					cad2 = "." + cad2;
				}
			}
		}
		donde.value = cad2;
	}
}

function validar(e)
{ 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    patron = /\d/; //ver nota 
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
} 
</script>
</head>

<body>
<form name="form_vale_vista" id="form_vale_vista" method="post">
<?php
	$factura = $_POST['factura'];
	$doc = $_POST['doc'];
	$rut = $_POST['rut'];
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td id="Normal" colspan="2"><hr /></td>
  </tr>
  <tr>
  <td id="Normal" colspan="2">&nbsp;&nbsp;<label id="texto">Fecha de Hoy:</label><label style="color:#0000FF; font-size:11px; font-weight:bold"><?php echo $fecha;?></label><div id="datos" style="float:right; clear:none; vertical-align:top; margin-right:10px; margin-top:-15px;"><label style="color:#0000FF; font-size:12px; font-weight:bold;">Datos Obligatorios(*)</label></div></td>
  </tr>
  <tr>
    <td id="Normal" colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td id="Normal" width="18%">&nbsp;&nbsp;<label id="texto">N&deg; Vale Vista</label></td>
    <td id="Normal" width="82%"><input type="text" name="txtVale" onkeypress="return validar(event)" />&nbsp;<label class="asterisco">*</label></td>
  </tr>
  <tr>
    <td id="Normal"><label id="texto">&nbsp;&nbsp;Monto Pagar ($)</label></td>
    <td id="Normal"><input type="text" name="txtMonto" onkeyup="puntitos(this,this.value.charAt(this.value.length-1))" />&nbsp;<label class="asterisco">*</label></td>
  </tr>
  <tr>
    <td id="Normal"><label id="texto">&nbsp;&nbsp;Banco</label></td>
    <td id="Normal"><select name="cmb_Banco" id="cmb_Banco">
        <option value="0">--BANCO--</option>
        <?php
			$con = new Conexion();
    		$con2 = $con->conexionBD("fpproduccion");
			$sql = "select BancoCod,BancoNombre from banco";
			$resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
			while ($row = mysql_fetch_row($resultado))
			{
				echo "<option value='".$row[0]."'>".$row[1]."</option>";
			}
            $con->cerrarBD();
		?>
      </select>&nbsp;<label class="asterisco">*</label></td>
  </tr>
  <tr>
    <td id="Normal">&nbsp;</td>
    <td id="Normal"><div id="mensaje"></div></td>
  </tr>
  <tr>
    <td id="Normal" colspan="2"><hr /></td>
  </tr>
  <tr>
    <td id="Normal">&nbsp;</td>
    <td id="Normal"><input type="button" name="btn_Guardar" id="btn_Guardar" value=" " class="guardar" />
	<input type="hidden" name="txtFactura" id="txtFactura" value="<?php echo $factura;?>" />
	<input name="txtDoc" id="txtDoc" type="hidden" value="<?php echo $doc;?>" />
    <input type="hidden" name="txtRut" id="txtRut" value="<?php echo $rut?>" /></td>
  </tr>
  <tr>
  <td id="Normal">&nbsp;</td>
  <td id="Normal">&nbsp;</td>
  </tr>
</table>
</form>
</body>
<script>
$('#btn_Guardar').click(function() 
{ 
        $.ajax({
            type: 'POST',
            url: 'Contabilidad/Ingresa_Vale_Vista.php',
            data: $('#form_vale_vista').serialize(),
            success: function(data) {
                $('#mensaje').html(data);
            }
        })
});
</script>
</html>
